package com.three.work.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import com.three.work.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import com.three.work.bean.Department;
import com.three.work.bean.result.ResultPage;
import com.three.work.controller.model.ApiResultModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2020-04-02
 */
@Controller
@RequestMapping("/bus/department")
public class DepartmentController extends BaseController{
     /** 主页面 */
    @RequestMapping("main.html")
    public String main(){
       return  "DepartmentMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @RequestMapping(value = "/addDepartmentHtml")
    public String addDepartmentHtml( ){
             return "/DepartmentAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "/editDepartmentHtml")
    public String editDepartmentHtml(Integer id ,Model model ){
           model.addAttribute("department",departmentService.selectDepartmentByIdDepartment(id));
             return "/DepartmentEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "/showDepartmentHtml")
    public String showDepartmentHtml(Integer id ,Model model ){
           model.addAttribute("department",departmentService.selectDepartmentByIdDepartment(id));
             return "/DepartmentShow";
    }


    /** 分页查询Department
     * @param page  页码
     * @param limit  查几条
     * @param department  前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "/findDepartmentByPage")
    @ResponseBody
    public ResultPage findDepartmentByPage(Integer page, Integer limit,Department department){
             return departmentService.findDepartmentByPage(page,limit,department);
    }

    /** 添加Department
     * @param department  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "/addDepartment")
    @ResponseBody
    public ApiResultModel saveDepartment(Department department  ){
             return departmentService.addDepartment(department);
    }

    /** 编辑Department
     * @param department  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "/editDepartment")
    @ResponseBody
    public ApiResultModel editDepartment(Department department  ){
             return departmentService.editDepartment(department);
    }



    /** 删除一条Department
     * @param id  前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "/delDepartment")
    @ResponseBody
    public ApiResultModel delDepartment( Integer id  ){
             return departmentService.delDepartment(id);
    }


}
